package com.softeem.ssm2.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.softeem.ssm2.dao.StudentMapper;
import com.softeem.ssm2.entity.Student;
import com.softeem.ssm2.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author mrchai
 * @Date 2019/10/12 10:35
 */
@Transactional
@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public boolean add(Student stu) {
        return studentMapper.insert(stu) > 0;
    }

    @Override
    public List<Student> queryAll() {
        return studentMapper.selectAll();
    }

    @Override
    public Student queryById(Integer id) {
        return studentMapper.selectById(id);
    }

    @Override
    public PageInfo<Student> queryByPage(Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);
        List<Student> list = studentMapper.selectAll();
        return new PageInfo<>(list);
    }
}
